package com.vhall.component.controller.tag;

import com.vhall.component.entity.tag.vo.*;
import com.vhall.component.plugin.common.enums.OperateTypeEnum;
import com.vhall.component.service.annotation.OperateLog;
import com.vhall.component.service.tag.PageChannelService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 频道管理
 *
 * @author shimingming
 * @since 2023/4/12 17:19
 */
@Slf4j
@RestController
@RequestMapping("/v4/admin/page_channel")
public class PageChannelController {

    @Resource
    PageChannelService pageChannelService;


    /**
     * 保存
     */
    @PostMapping("/save-channel")
    @OperateLog(module = "频道管理", type = OperateTypeEnum.CREATE, name = "保存")
    public Boolean save(@Validated PageChannelReqVO reqVO) {
        return pageChannelService.saveInfo(reqVO);
    }


    /**
     * 列表，一棵树
     */
    @PostMapping("/list")
    public List<PageChannelListRspVO> list(PageChannelListReqVO reqVO) {
        return pageChannelService.listInfo(reqVO);
    }

    /**
     * 列表，不是树
     */
//    @PostMapping("/list_all")
    public List<PageChannelListRspVO> listAll(PageChannelListReqVO reqVO) {
        return pageChannelService.listAllInfo(reqVO);
    }


    /**
     * 更新
     */
    @PostMapping("/update")
    @OperateLog(module = "频道管理", type = OperateTypeEnum.UPDATE, name = "更新")
    public Boolean update(@Validated PageChannelReqVO reqVO) {
        return pageChannelService.updateInfo(reqVO);
    }

    /**
     * 排序
     */
    @GetMapping("/sort")
    @OperateLog(module = "频道管理", type = OperateTypeEnum.UPDATE, name = "排序")
    public Boolean sort(@Validated PageChannelSortReqVO reqVO) {
        return pageChannelService.sortInfo(reqVO);
    }

    /**
     * 是否启用
     */
    @PostMapping("/change_status")
    @OperateLog(module = "频道管理", type = OperateTypeEnum.UPDATE, name = "是否启用")
    public Boolean changeState(@Validated PageChannelChangeReqVO reqVO) {
        return pageChannelService.changeInfo(reqVO, "status");
    }

    /**
     * 是否显示
     */
    @PostMapping("/change_show")
    @OperateLog(module = "频道管理", type = OperateTypeEnum.UPDATE, name = "是否显示")
    public Boolean changeShow(@Validated PageChannelChangeReqVO reqVO) {
        return pageChannelService.changeInfo(reqVO, "show");
    }

    /**
     * 删除
     */
    @GetMapping("/delete")
    @OperateLog(module = "频道管理", type = OperateTypeEnum.DELETE, name = "删除")
    public Boolean delete(@RequestParam("id") Integer id) {
        return pageChannelService.delete(id);
    }

    /**
     * 根据id 查询频道信息
     */
    @GetMapping("/info")
    public List<PageChannelRspVO> info(@RequestParam("ids") List<Integer> ids) {
        return pageChannelService.getInfo(ids);
    }



}
